﻿@using LERP.Web.App_Start
@{
    var menu = MenuConfigManger.Instance.Items;
    var action = this.Request.RequestContext.RouteData.Values["action"].ToString().ToLower();
    var contrller = this.Request.RequestContext.RouteData.Values["controller"].ToString().ToLower();
    var topMenu = new MenuItem();
    var currentMenu = new MenuItem();
}
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8" />
    <title>@ViewBag.Title - 物流管理系统</title>
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <meta name="viewport" content="width=device-width" />
    @*<link href="@Url.Content("~/Content/css/transdmin.css")" rel="stylesheet" />*@
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" />

    <link href="@Url.Content("~/Content/jqueryfiletree/jqueryFileTree.css")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/jqueryautocomplete/jquery.autocomplete.css")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/jqueryautocomplete/jquery.autocomplete.css")" rel="stylesheet" />

    @Styles.Render("~/Content/themes/base/css")
</head>
<body>


    <div class="header">
        <span class="logo"></span>
        <span class="logout">@Html.Action("UserInfo", "Home")</span>
    </div>
    <!-- h1 tag stays for the logo, you can use the a tag for linking the index page -->
    @*<h1><a href="@Url.Action("Index", "Order")"><span>物流管理系统</span></a></h1>*@

    <!-- You can name the links with lowercase, they will be transformed to uppercase by CSS, we prefered to name them with uppercase to have the same effect with disabled stylesheet -->
    <ul class="mainNav">
        @foreach (var item in menu)
        {
            var paras = new RouteValueDictionary();
            var attrs = new Dictionary<string, object>();
            if (null != item.Parameters)
            {
                foreach (var para in item.Parameters)
                {
                    paras.Add(para.Name, para.Value);
                }
            }
            if ((action == item.Action && contrller == item.Contrller) || (null != item.Items && item.Items.Any(m => action == m.Action && contrller == m.Contrller)) || (null != item.Items && item.Items.Any(m => null != m.Items && m.Items.Any(x => action == x.Action && contrller == x.Contrller))))
            {
                attrs.Add("class", "active");
                topMenu = item;
            }

            <li>@Html.ActionLinkEx(item.Name, item.Action, item.Contrller, paras, attrs)</li>
        }
        <li class="logout"></li>
    </ul>

    <div class="container">
        <div class="sidebar">
            <ul class="sideNav">
                @foreach (var item in topMenu.Items)
                {
                    var paras = new RouteValueDictionary();
                    var attrs = new Dictionary<string, object>();
                    if (null != item.Parameters)
                    {
                        foreach (var para in item.Parameters)
                        {
                            paras.Add(para.Name, para.Value);
                        }
                    }
                    if ((action == item.Action && contrller == item.Contrller) || (null != item.Items && item.Items.Any(m => action == m.Action && contrller == m.Contrller)))
                    {
                        attrs.Add("class", "active");
                        currentMenu = item;
                    }
                    if (!item.IsHide)
                    {
                    <li>@Html.ActionLinkEx(item.Name, item.Action, item.Contrller, paras, attrs)</li>
                    }
                }


            </ul>
        </div>
        <div class="main">
            <!-- h2 stays for breadcrumbs -->
            @{
                var currentMenuparas = new RouteValueDictionary();
                if (null != currentMenu.Parameters)
                {
                    foreach (var para in currentMenu.Parameters)
                    {
                        currentMenuparas.Add(para.Name, para.Value);
                    }
                }
                var topMenuparas = new RouteValueDictionary();
                if (null != topMenu.Parameters)
                {
                    foreach (var para in topMenu.Parameters)
                    {
                        topMenuparas.Add(para.Name, para.Value);
                    }
                }
            }
            <h2 class="breadcrumbs">
                @if (!(action == topMenu.Action && contrller == topMenu.Contrller))
                {
                    @Html.ActionLink(topMenu.Name, topMenu.Action, topMenu.Contrller, topMenuparas, new Dictionary<string, object>()) @(new MvcHtmlString("&raquo;"))
                }
                @if (!(action == currentMenu.Action && contrller == currentMenu.Contrller))
                {
                    @Html.ActionLink(currentMenu.Name, currentMenu.Action, currentMenu.Contrller, currentMenuparas, new Dictionary<string, object>())@(new MvcHtmlString("&raquo;"))
                }
                @ViewBag.Title
            </h2>
            @RenderBody()
        </div>
        <div class="cFix"></div>
    </div>
    <div class="footer2">欢迎使用订单管理系统. <a href="@Url.Action("Create", "Bug")">问题反馈?</a></div>

    @Scripts.Render("~/bundles/jquery")

    @System.Web.Optimization.Scripts.Render("~/bundles/jqueryval")

    @System.Web.Optimization.Scripts.Render("~/bundles/jqueryui")
    
    
    <script type="text/javascript" src="@Url.Content("~/Scripts/jqueryautocomplete/jquery.bgiframe.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/jqueryautocomplete/jquery.ajaxQueue.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/jqueryautocomplete/jquery.autocomplete.js")"></script>

    @RenderSection("scripts", required: false)
    <script type="text/javascript">

        $(function () {
            $("input.dataselect").live("focus", function () {
                $(this).datepicker();
            });


        })</script>
</body>
</html>
